﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GreyGate.Utils
{
    class DrawModel
    {
        public void Draw( Model model,
                          Matrix[] boneTransforms,
                          Matrix lookAt, Matrix fieldOfView,  
                          Vector3 position,                                           
                          float scale, float angle)
        {
            model.CopyAbsoluteBoneTransformsTo(boneTransforms);
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {

                    effect.World = boneTransforms[mesh.ParentBone.Index] *
                                   Matrix.CreateTranslation(position) * 
                                   Matrix.CreateRotationY(MathHelper.ToRadians(angle)) * 
                                   Matrix.CreateScale(scale)
                                   ;
                    effect.View = lookAt;
                    effect.Projection = effect.Projection = fieldOfView; ;

                    effect.EnableDefaultLighting();
                }
                mesh.Draw();
            }
        }     
    }
}